local items = {
	settingsfile = "PTO.json",
	callback = GUICallback,
	{ type = "separator" },
	{ type = "title", text = "防战 |c0000CED1PvE" },
	{ type = "separator" },
	{ type = "title", text = "|cffFFFF00输出循环" },
	{ type = "separator" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(11578))..":26:26\124t  无脑冲锋", tooltip = "无脑冲锋", enabled = true, key = "Charge" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(20252))..":26:26\124t  无脑拦截", tooltip = "无脑拦截", enabled = true, key = "Intercept" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(57823))..":26:26\124t  复仇", tooltip = "复仇", enabled = true, key = "Revenge" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(47488))..":26:26\124t  盾牌猛击", tooltip = "盾牌猛击", enabled = true, key = "ShieldSlam" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(47498))..":26:26\124t  毁灭打击", tooltip = "毁灭打击", enabled = true, key = "Devastate" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(11574))..":26:26\124t  撕裂", tooltip = "撕裂", enabled = true, key = "Rend" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(20569))..":26:26\124t  智能顺劈斩英勇打击 ", tooltip = "数量控制", enabled = true, value = 2, key = "Cleave" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(57755))..":26:26\124t  英勇投掷", tooltip = "英勇投掷", enabled = true, key = "HeroicThrow" },
	{ type = "separator" },
	{ type = "title", text = "|cffFFFF00AOE功能" },
	{ type = "separator" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(46968))..":26:26\124t 使用 震荡波 怪物数量 >", tooltip = "震荡波 数量", enabled = true, value = 2, key = "Shockwave" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(25264))..":26:26\124t 使用 雷霆一击 怪物数量 >", tooltip = "雷霆一击 数量", enabled = true, value = 2, key = "ThunderClap" },
	{ type = "separator" },
    { type = "page", number = 1, text = "|cffFFFF00保命功能|r" },
	{ type = "separator" },	
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(18499))..":26:26\124t  狂暴之怒解恐", tooltip = "狂暴之怒", enabled = true, key = "BerserkerRage" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(12975))..":26:26\124t  破釜沉舟 HP% <", tooltip = "破釜沉舟< HP%", enabled = true, value = 50, key = "LastStand" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(2565))..":26:26\124t  盾牌格挡 HP% <", tooltip = "盾牌格挡< HP%", enabled = true, value = 80, key = "ShieldBlock" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(871))..":26:26\124t  盾墙 HP% <", tooltip = "盾墙< HP%", enabled = true, value = 50, key = "ShieldWall" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(55694))..":26:26\124t  狂暴回复 HP% <", tooltip = "狂暴回复< HP%", enabled = true, value = 50, key = "EnragedRegeneration" },
	{ type = "entry", text = "\124T"..GetItemIcon(36894)..":26:26\124t 使用 治疗石 HP% <", tooltip = "治疗石", enabled = true, value = 60, key = "FelHealthstone" },
	{ type = "separator" },
	{ type = "page", number = 2, text = "|cFF00FF00辅助功能|r" },
	{ type = "separator" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(6603))..":26:26\124t  自动目标", tooltip = "自动目标", enabled = true, key = "AutoAttack" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(2687))..":26:26\124t  血性狂暴", tooltip = "血性狂暴补怒", enabled = true, key = "Bloodrage" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(47488))..":26:26\124t  盾猛驱散", tooltip = "盾牌猛击驱散魔法", enabled = true, key = "ShieldSlamQS" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(72))..":26:26\124t  盾击", tooltip = "盾击打断", enabled = true, key = "ShieldBash" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(3411))..":26:26\124t  援护", tooltip = "援护队友", enabled = true, key = "Intervene" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(11578))..":26:26\124t  冲锋打断", tooltip = "冲锋打断", enabled = true, key = "ChargeDD" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(20252))..":26:26\124t  拦截打断", tooltip = "拦截打断", enabled = true, key = "InterceptDD" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(47440))..":26:26\124t  怒吼 <", tooltip = "1为战斗怒吼2为命令怒吼", enabled = true, value = 2, key = "Shout" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(51306))..":26:26\124t  调试", tooltip = "显示调试信息", enabled = false, key = "debug" },
	{ type = "page", number = 3, text = "|cFF00FF00嘲讽功能|r" },
	{ type = "separator" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(694))..":26:26\124t  惩戒痛击", tooltip = "惩戒痛击嘲讽", enabled = true, key = "MockingBlow" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(355))..":26:26\124t  嘲讽", tooltip = "嘲讽", enabled = true, key = "Taunt" },
	{ type = "entry", text = "\124T"..select(3, GetSpellInfo(57755))..":26:26\124t  英勇投掷", tooltip = "英勇投掷嘲讽", enabled = true, key = "HeroicThrowCF" },
};
 
local function GetSetting(name)
    for k, v in ipairs(items) do
        if v.type == "entry"
         and v.key ~= nil
         and v.key == name then
            return v.value, v.enabled
        end
    end
end;

local function OnLoad()
	ni.GUI.AddFrame("PTO", items);
end;

local function OnUnLoad()  
	ni.GUI.DestroyFrame("PTO");
end;

local spells = {
	--General
	WarStomp = {id = 20549, name = GetSpellInfo(20549)},  --战争践踏
	AutoAttack = {id = 6603, name = GetSpellInfo(6603)},  --攻击
	Throw = {id = 2764, name = GetSpellInfo(2764)},  --投掷
	FelHealthstone = {id = 36894, name = GetItemInfo(36894)},  --治疗石
	--Arms
	ThunderClap = {id = 25264, name = GetSpellInfo(25264)},  --雷霆一击
	Charge = {id = 11578, name = GetSpellInfo(11578)},  --冲锋
	Hamstring = {id = 1715, name = GetSpellInfo(1715)},  --断筋
	Rend = {id = 11574, name = GetSpellInfo(11574)},  --撕裂
	BattleStance = {id = 2457, name = GetSpellInfo(2457)},  --战斗姿态
	Retaliation = {id = 20230, name = GetSpellInfo(20230)}, --反击风暴
	MockingBlow = {id = 694, name = GetSpellInfo(694)},  --惩戒痛击
	Overpower = {id = 7384, name = GetSpellInfo(7384)},  --压制
	HeroicStrike = {id = 47450, name = GetSpellInfo(47450)},  --英勇打击
	HeroicThrow = {id = 57755, name = GetSpellInfo(57755)},  --英勇投掷
	--Fury
	BerserkerStance = {id = 2458, name = GetSpellInfo(2458)},  --狂暴姿态
	Recklessness = {id = 1719, name = GetSpellInfo(1719)}, --鲁莽
	Cleave = {id = 47520, name = GetSpellInfo(47520)}, --顺劈斩
	Execute = {id = 25234, name = GetSpellInfo(25234)}, --斩杀
	Whirlwind = {id = 1680, name = GetSpellInfo(1680)},--旋风斩
	DemoralizingShout = {id = 25202, name = GetSpellInfo(25202)}, --挫志怒吼
	VictoryRush = {id = 34428, name = GetSpellInfo(34428)}, --乘胜追击
	Slam = {id = 25241, name = GetSpellInfo(25241)}, --猛击
	IntimidatingShout = {id = 5246, name = GetSpellInfo(5246)}, --破胆怒吼
	Pummel = {id = 6552, name = GetSpellInfo(6552)}, --拳击
	BerserkerRage = {id = 18499, name = GetSpellInfo(18499)}, --狂暴之怒
	EnragedRegeneration = {id = 55694, name = GetSpellInfo(55694)}, --狂暴回复
	ChallengingShout = {id = 1161, name = GetSpellInfo(1161)},  --挑战怒吼
	Intercept = {id = 20252, name = GetSpellInfo(20252)},  --拦截
	BattleShout = {id = 25289, name = GetSpellInfo(25289)},  --战斗怒吼
	CommandingShout = {id = 47440, name = GetSpellInfo(47440)},  --命令怒吼
	--Protection
	ConcussionBlow = {id = 12809, name = GetSpellInfo(12809)},  --震荡猛击
	Vigilance = {id = 50720, name = GetSpellInfo(50720)},  --警戒
	Taunt = {id = 355, name = GetSpellInfo(355)},  --嘲讽
	Intervene = {id = 3411, name = GetSpellInfo(3411)},  --援护
	SunderArmor = {id = 7386, name = GetSpellInfo(7386)}, --破甲攻击
	Disarm = {id = 676, name = GetSpellInfo(676)},  --缴械
	SpellReflection = {id = 23920, name = GetSpellInfo(23920)},  --法术反射
	Shockwave = {id = 46968, name = GetSpellInfo(46968)},  --震荡波
	ShieldWall = {id = 871, name = GetSpellInfo(871)},  --盾墙
	ShieldSlam = {id = 47488, name = GetSpellInfo(47488)},  --盾牌猛击
	ShieldBlock = {id = 2565, name = GetSpellInfo(2565)},  --盾牌格挡
	Revenge = {id = 57823, name = GetSpellInfo(57823)},  --复仇
	DefensiveStance = {id = 71, name = GetSpellInfo(71)},  --防御姿态
	ShieldBash = {id = 72, name = GetSpellInfo(72)},  --盾击
	Devastate = {id = 47498, name = GetSpellInfo(47498)}, --毁灭打击
	LastStand = {id = 12975, name = GetSpellInfo(12975)},  --破釜沉舟
	Bloodrage = {id = 2687, name = GetSpellInfo(2687)}  --血性狂暴
};

local Cache = {
		enemiesn = ni.player.enemiesinrange(30),
};

local incombat = false
local playerguid = UnitGUID("player")
local revengeAvalible = false

local function CombatEventCatcher(event, ...)
	if event == "COMBAT_LOG_EVENT_UNFILTERED" then
		local _, eventType, _, _, _, destGUID = ...
		if destGUID == playerguid and eventType == "SWING_MISSED" then
			local misstype = select(9, ...)
			if misstype == "BLOCK" or misstype == "DODGE" or misstype == "PARRY" then
				revengeAvalible = true
			end
		end
	end
	if event == "PLAYER_REGEN_DISABLED" then
		incombat = true
	elseif event == "PLAYER_REGEN_ENABLED" then
		incombat = false
	end
end

local queue = {
	"debug",
	"Cache",
	"Pause",
	"AutoAttack",
	"Fel Healthstone",
	"BerserkerRage",
	"SpellReflection",
	"ShieldBlock",
	"ShieldWall",
	"LastStand",
	"EnragedRegeneration",
	"Bloodrage",
	"MockingBlow",
	"Taunt",
	"Intervene",
	"ShieldBash",
	"ChargeDD",
	"InterceptDD",
	"Charge",
	"Intercept",
	"ShieldSlamQS",
	"Cleave",
	"Revenge",
	"ThunderClap",
	"Shockwave",
	"ShieldSlam",
	"Devastate",
	"HeroicThrow",
	"Rend",
	"Shout",
	
};

local function FacingLosCast(spell, tar)
	if ni.player.isfacing(tar, 145) and ni.player.los(tar) then
		ni.spell.cast(spell, tar)
		
		return true
	end
	return false
end;

local function Tank(t)
	if ni.unit.aura(t, 9634)
    or ni.unit.aura(t, 48263)
	or ni.unit.aura(t, 71)
    or ni.unit.aura(t, 25780) then
		return true
	end
	return false
end

local function Usableplayer(id)
   if ni.spell.available(id) and UnitAffectingCombat("player") then
		return true
	end
	return false
end;

local function ValidUsable(id, tar)
	if ni.spell.available(id) and ni.spell.valid(tar, id, true, true) and UnitAffectingCombat(tar) then
		return true
	end
	return false
end;

local function Ddmb(tar)
   if ni.unit.iscasting(tar) or ni.unit.ischanneling(tar) then
        return true end
	return false
 end;

local abilities = {

	["Cache"] = function()  
		Cache.enemiesn = ni.player.enemiesinrange(30)
	end,

	 ["Pause"] = function()  --停止条件
		if IsMounted() or UnitIsDeadOrGhost("player") 
		 then
			return true
		end
	end,
	
	["AutoAttack"] = function()  --自动攻击
	local _, enabled = GetSetting("AutoAttack")
		if enabled then
		  if UnitAffectingCombat("player")
		    and (not IsCurrentSpell(spells.AutoAttack.id) or not UnitCanAttack("player", "target"))
	      then
			ni.spell.cast(spells.AutoAttack.name)  return true;
		  end
		end
	end,

	["ShieldBlock"] = function()  --盾牌格挡
	local value, enabled = GetSetting("ShieldBlock")
		if enabled then
		   if Usableplayer(spells.ShieldBlock.id)
			  and ni.player.hp() <= value 
		   then
				ni.spell.cast(spells.ShieldWall.name) return true;
		   end 
		end 
	end,

	["ShieldWall"] = function()  --盾墙
	local value, enabled = GetSetting("ShieldWall")
		if enabled then
		   if Usableplayer(spells.ShieldWall.id)
			  and ni.player.hp() <= value 
		   then
				ni.spell.cast(spells.ShieldWall.name) return true;
		   end
		end 
	end,

	["EnragedRegeneration"] = function()  --狂暴回复
	local value, enabled = GetSetting("EnragedRegeneration")
		if enabled then
		   if Usableplayer(spells.EnragedRegeneration.id)
			  and ni.player.hp() <= value 
		   then
				ni.spell.cast(spells.EnragedRegeneration.name)	return true;
		   end
		end 
	end,

	["BerserkerRage"] = function()  --狂暴之怒解除恐惧
	local _, enabled = GetSetting("BerserkerRage")
		if enabled then
		   if ni.player.isfleeing()
		      and Usableplayer(spells.BerserkerRage.id)
		   then
				ni.spell.cast(spells.BerserkerRage.name) return true;
		   end
		end 
	end,

	["LastStand"] = function()  --破釜沉舟
	local value, enabled = GetSetting("LastStand")
		if enabled then
		   if Usableplayer(spells.LastStand.id)
			  and ni.player.hp() <= value 
		   then
				ni.spell.cast(spells.LastStand.name)	return true;
		   end
		end 
	end,

	["Fel Healthstone"] = function()  --治疗石
	local value, enabled = GetSetting("FelHealthstone")
		if enabled  then
			if UnitAffectingCombat("player")
			and ni.player.hp() <= value
			and ni.player.itemready(spells.FelHealthstone.id)  then
				ni.player.useitem(spells.FelHealthstone.name)
				return true; end
		end
	end,

	["Taunt"] = function()  --嘲讽
    local _, enabled = GetSetting("Taunt")
      if enabled then 
         for i = 1, #Cache.enemiesn do
			local target = Cache.enemiesn[i].guid
			local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
			if ni.unit.exists(targett)	
			   and ValidUsable(spells.Taunt.id,target)
			   and Tank(targett) == false
			then
			   ni.spell.cast(spells.Taunt.name, target) return true
			end
         end
      end
    end,

	["HeroicThrowCF"] = function()  --英勇投掷嘲讽
    local _, enabled = GetSetting("HeroicThrowCF")
      if enabled then 
         for i = 1, #Cache.enemiesn do
			local target = Cache.enemiesn[i].guid
			local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
			if ni.unit.exists(targett)	
			   and ValidUsable(spells.HeroicThrow.id,target)
			   and Tank(targett) == false
			then
			   ni.spell.cast(spells.HeroicThrow.name, target) return true
			end
         end
      end
    end,

	["MockingBlow"] = function()  --惩戒痛击嘲讽
	
    local _, enabled = GetSetting("MockingBlow")
      if enabled then 
         for i = 1, #Cache.enemiesn do
			local target = Cache.enemiesn[i].guid
			local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
			if ni.unit.exists(targett)	
			   and ValidUsable(spells.MockingBlow.id,target)
			   and Tank(targett) == false
			then
			   ni.spell.cast(spells.MockingBlow.name, target) return true
			end
         end
      end
    end,

	["Intervene"] = function()  --援护
    local _, enabled = GetSetting("Intervene")
      if enabled then 
         for i = 1, #Cache.enemiesn do
			local target = Cache.enemiesn[i].guid
			local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
			if ni.unit.exists(targett)	
			   and ValidUsable(spells.Intervene.id,target)
			   and targett:istank() == false
			then
			   ni.spell.cast(spells.Intervene.name, target) return true
			end
         end
      end
    end,

	["Charge"] = function()   --冲锋
	local _, enabled = GetSetting("Charge")
		if enabled  then
			for i = 1, #Cache.enemiesn do
				local target = Cache.enemiesn[i].guid
				local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
				if  ni.unit.exists(targett) 
						and ValidUsable(spells.Charge.id, target)
				then
					ni.spell.cast(spells.Charge.name, target)	return true
				end
			end
		end
	end,

	["Intercept"] = function()   --拦截
	local _, enabled = GetSetting("Intercept")
		if enabled  then
			for i = 1, #Cache.enemiesn do
				local target = Cache.enemiesn[i].guid
				local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
				if  ni.unit.exists(targett) 
						and ValidUsable(spells.Intercept.id, target)
				then
					ni.spell.cast(spells.Intercept.name, target)	return true
				end
			end
		end
	end,

	 ["ShieldSlamQS"] = function()     --盾猛驱散
	local _, enabled = GetSetting("ShieldSlamQS")
		if enabled  then
			for i = 1, #Cache.enemiesn do
				local target = Cache.enemiesn[i].guid
				local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
				if  ni.unit.exists(targett) 
				    and ni.unit.bufftype(target, "Magic")
					and ValidUsable(spells.ShieldSlam.id,target)
				then
					ni.spell.cast(spells.ShieldSlam.name, target)	return true
				end
			end
		end
	end,
	
	["SpellReflection"] = function()   --法术反射
	local _, enabled = GetSetting("SpellReflection")
		if enabled  then
			for i = 1, #Cache.enemiesn do
				local target = Cache.enemiesn[i].guid
				local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
				if  ni.unit.exists(targett) 
						and Ddmb(target)
						and Usableplayer(spells.SpellReflection.id)
				then
					ni.spell.cast(spells.SpellReflection.name)	return true
				end
			end
		end
	end,

	["ShieldBash"] = function()   --盾击打断
	local _, enabled = GetSetting("ShieldBash")
		if enabled  then
			for i = 1, #Cache.enemiesn do
				local target = Cache.enemiesn[i].guid
				local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
				if  ni.unit.exists(targett) 
						and Ddmb(target)
						and ValidUsable(spells.ShieldBash.id, target)
				then
					ni.spell.cast(spells.ShieldBash.name, target)	return true
				end
			end
		end
	end,

	["ChargeDD"] = function()   --冲锋打断
	local _, enabled = GetSetting("ChargeDD")
		if enabled  then
			for i = 1, #Cache.enemiesn do
				local target = Cache.enemiesn[i].guid
				local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
				if  ni.unit.exists(targett) 
						and Ddmb(target)
						and ValidUsable(spells.Charge.id, target)
				then
					ni.spell.cast(spells.Charge.name, target)	return true
				end
			end
		end
	end,

	["InterceptDD"] = function()   --拦截打断
	local _, enabled = GetSetting("InterceptDD")
		if enabled  then
			for i = 1, #Cache.enemiesn do
				local target = Cache.enemiesn[i].guid
				local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
				if  ni.unit.exists(targett) 
						and Ddmb(target)
						and ValidUsable(spells.Intercept.id, target)
				then
					ni.spell.cast(spells.Intercept.name, target)	return true
				end
			end
		end
	end,

	["Bloodrage"] = function()
	local _, enabled = GetSetting("Bloodrage")  --血性狂暴
        if enabled then
		   if Usableplayer(spells.Bloodrage.id)
		      and ni.player.power() <70 
		   then
		     ni.spell.cast(spells.Bloodrage.name)  return true
		   end
		end
    end,
	
	["Revenge"] = function()  --复仇
	local _, enabled = GetSetting("Revenge")
		if enabled then
		  if (revengeAvalible or IsUsableSpell(spells.Revenge.id)) 
		     and ValidUsable(spells.Revenge.id, "target") 
		  then
				FacingLosCast(spells.Revenge.name, "target")
		        revengeAvalible = false
		   return true
		   end
	    end
	end,

	["ShieldSlam"] = function()  --盾猛
	local _, enabled = GetSetting("ShieldSlam")
		if enabled then
		   if ValidUsable(spells.ShieldSlam.name, "target") 
		   then
		      ni.spell.cast(spells.ShieldSlam.name, "target") 	return true
		   end
		end
	end,

	["Rend"] = function()  --自动流血
	local _, enabled = GetSetting("Rend")
        if enabled  then
			for i = 1, #Cache.enemiesn do
				local target = Cache.enemiesn[i].guid
				local x, y, z, facing, unittype, targett, height = ni.unit.info(target)
				if  ni.unit.exists(targett)
					and ValidUsable(spells.Rend.id,target)
					and not unittype == 9
					and not ni.unit.debuff(target,spells.Rend.id, "player")
				then
					ni.spell.cast(spells.Rend.name, target) return true
				end
			end
		end
	end,

	["Cleave"] = function()   --顺劈斩或者英勇打击 数量
	local value, enabled = GetSetting("Cleave")
	local enear = #ni.player.enemiesinrange(10)
		if enabled then 
		   if enear >= value  then
			  if not IsCurrentSpell(spells.Cleave.id) and
				 ValidUsable(spells.Cleave.id,"target")
			  then
				 ni.spell.cast(spells.Cleave.name, "target")  return true
			  end
		   elseif not IsCurrentSpell(spells.HeroicStrike.id) 
				  and ValidUsable(spells.HeroicStrike.id,"target") 
           then
				  ni.spell.cast(spells.HeroicStrike.name, "target") return true  
		   end
	    end
	end,

	["Devastate"] = function()  --毁灭打击
	local _, enabled = GetSetting("Devastate")
		if enabled then
		   if  ValidUsable(spells.Devastate.name, "target") 
		      and (ni.unit.debuffremaining("target", 58567)<5 or ni.unit.debuffstacks("target", 58567)<5)
           then ni.spell.cast(spells.Devastate.name, "target") return true
		   end
		end
	end,

	["HeroicThrow"] = function()  --英勇投掷
	local _, enabled = GetSetting("HeroicThrow")
		if enabled then
		   if UnitAffectingCombat("target")
		      and ValidUsable(spells.HeroicThrow.name, "target") 
		   then
		       ni.spell.cast(spells.HeroicThrow.name, "target") 	return true 
		   end
		end
	end,

	["ThunderClap"] = function()  --雷霆一击 
	local value, enabled = GetSetting("ThunderClap")
	local enear = #ni.player.enemiesinrange(10)
		if enabled then
		   if enear >= value 
		      and ni.spell.available(spells.ThunderClap.name) 
		   then
			  ni.spell.cast(spells.ThunderClap.name)  return true
		   end
	    end
	end,

	["Shout"] = function()  --1为战斗怒吼 其他为命令怒吼
	local value, enabled = GetSetting("Shout")
		if enabled  then
		  if value == 1 then
		    if not ni.player.buff(spells.BattleShout.id) 
			   and ni.spell.available(spells.BattleShout.id)
		    then ni.spell.cast(spells.BattleShout.name)   return true 
		    end
		  elseif not ni.player.buff(spells.CommandingShout.id)
		          and ni.spell.available(spells.CommandingShout.id)
		  then ni.spell.cast(spells.CommandingShout.name)  return true	
		  end
		end
	end,

	["Shockwave"] = function()  --震荡波 
	local value, enabled = GetSetting("Shockwave")
	local enear = #ni.player.enemiesinrange(10)
		if enabled then
		   if enear >= value 
		      and ni.spell.available(spells.Shockwave.name) 
		      and FacingLosCast(spells.Shockwave.name, "target") then
		   return true
		   end
		end
	end,
	["debug"] = function()  --调试
	local _, enabled = GetSetting("debug")
		if enabled then
		     ni.vars.debug = true
		else
             ni.vars.debug = false
		end
	end,
};
ni.bootstrap.profile("PTO", queue, abilities, OnLoad, OnUnLoad);	
